<?php
// +-------------------------------------------------------------------------------
// | DingZone [ A Rapid Development Framework For Dingtalk ]
// +-------------------------------------------------------------------------------
// | 文件相关Controller v1.0
// |
// | Copyright (c) 2014-2018 http://www.heimalanshi.com All rights reserved.
// | Author : Jie
// | Date : 2018-08-09
// +-------------------------------------------------------------------------------

namespace app\core\controller\enterprise;


class SmsController extends EnterpriseBaseController {

    public function __construct() {
        parent::__construct();
    }

    protected function _checkLogin() {
        switch (strtolower($this->request->action())) {
            case "sendcode":
                return "";
            default:
                return parent::_checkLogin();
        }
    }

    /**
     * 发送短信验证码
     */
    public function sendCode() {
        $this->_checkCaptcha("captchaCode");

        $mobile = input("post.mobile");

        $smsHelper = $this->_getSmsHelper();
        $response = $smsHelper->sendVerify($mobile);
        $this->_d("sendVerify. mobile = " . $mobile . ", response = " . json_encode($response));
        if ($response['status'] == 1) {
            $this->success("发送成功");
        } else {
            $this->error("发送失败：" . $response['info']);
        }
    }
}
